<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Compiling with libsoup</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="libsoup Reference Manual">
<link rel="up" href="ch01.html" title="Tutorial">
<link rel="prev" href="ch01.html" title="Tutorial">
<link rel="next" href="libsoup-client-howto.html" title="Soup Client Basics">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="ch01.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">libsoup Reference Manual</th>
<td><a accesskey="n" href="libsoup-client-howto.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="libsoup-build-howto"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle">Compiling with libsoup</span></h2>
<p>Compiling with libsoup — Notes on compiling</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsect2">
<a name="id591078"></a><h3>Using pkg-config</h3>
<p>
Like other GNOME libraries, <span class="application">libsoup</span> uses
<span class="application">pkg-config</span> to provide compiler options. The
package name is "<code class="literal">libsoup-2.4</code>". So in your
<code class="literal">configure</code> script, you might specify something like:
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function">PKG_CHECK_MODULES</span><span class="symbol">(</span><span class="normal">LIBSOUP</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">[</span><span class="normal">libsoup</span><span class="symbol">-</span><span class="number">2.4</span><span class="normal"> </span><span class="symbol">&gt;=</span><span class="normal"> </span><span class="number">2.26</span><span class="symbol">])</span>
<span class="function">AC_SUBST</span><span class="symbol">(</span><span class="normal">LIBSOUP_CFLAGS</span><span class="symbol">)</span>
<span class="function">AC_SUBST</span><span class="symbol">(</span><span class="normal">LIBSOUP_LIBS</span><span class="symbol">)</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
The "<code class="literal">2.4</code>" in the package name is the "API version"
(indicating "the version of the <span class="application">libsoup</span> API
that first appeared in version 2.4") and is essentially just part of
the package name.
</p>
<p>
If you are using any of the GNOME-specific features of
<span class="application">libsoup</span> (such as automatic proxy
configuration), you must require
"<code class="literal">libsoup-gnome-2.4</code>" instead:
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function">PKG_CHECK_MODULES</span><span class="symbol">(</span><span class="normal">LIBSOUP</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">[</span><span class="normal">libsoup</span><span class="symbol">-</span><span class="normal">gnome</span><span class="symbol">-</span><span class="number">2.4</span><span class="normal"> </span><span class="symbol">&gt;=</span><span class="normal"> </span><span class="number">2.26</span><span class="symbol">])</span>
<span class="function">AC_SUBST</span><span class="symbol">(</span><span class="normal">LIBSOUP_CFLAGS</span><span class="symbol">)</span>
<span class="function">AC_SUBST</span><span class="symbol">(</span><span class="normal">LIBSOUP_LIBS</span><span class="symbol">)</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
You can also make <span class="application">libsoup-gnome</span> an optional
dependency:
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function">PKG_CHECK_MODULES</span><span class="symbol">(</span><span class="normal">LIBSOUP_GNOME</span><span class="symbol">,</span>
<span class="normal">          </span><span class="symbol">[</span><span class="normal">libsoup</span><span class="symbol">-</span><span class="normal">gnome</span><span class="symbol">-</span><span class="number">2.4</span><span class="normal"> </span><span class="symbol">&gt;=</span><span class="normal"> </span><span class="number">2.26</span><span class="symbol">],</span>
<span class="normal">          </span><span class="symbol">[</span><span class="normal">LIBSOUP_CFLAGS</span><span class="symbol">=</span><span class="string">"$LIBSOUP_GNOME_CFLAGS"</span>
<span class="normal">           LIBSOUP_LIBS</span><span class="symbol">=</span><span class="string">"$LIBSOUP_GNOME_LIBS"</span>
<span class="normal">           </span><span class="function">AC_DEFINE</span><span class="symbol">(</span><span class="normal">HAVE_LIBSOUP_GNOME</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">[</span><span class="usertype">Have</span><span class="normal"> libsoup</span><span class="symbol">-</span><span class="normal">gnome</span><span class="symbol">])],</span>
<span class="normal">          </span><span class="symbol">[</span><span class="function">PKG_CHECK_MODULES</span><span class="symbol">(</span><span class="normal">LIBSOUP</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">[</span><span class="normal">libsoup</span><span class="symbol">-</span><span class="number">2.4</span><span class="normal"> </span><span class="symbol">&gt;=</span><span class="normal"> </span><span class="number">2.26</span><span class="symbol">])])</span>
<span class="function">AC_SUBST</span><span class="symbol">(</span><span class="normal">LIBSOUP_CFLAGS</span><span class="symbol">)</span>
<span class="function">AC_SUBST</span><span class="symbol">(</span><span class="normal">LIBSOUP_LIBS</span><span class="symbol">)</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
This will allow the application to be built with either plain
<span class="application">libsoup</span> or with
<span class="application">libsoup-gnome</span>, and it will define the C
preprocessor symbol <code class="literal">HAVE_LIBSOUP_GNOME</code> if
<span class="application">libsoup-gnome</span> features are available.
</p>
</div>
<hr>
<div class="refsect2">
<a name="id527732"></a><h3>Headers</h3>
<p>
Code using <span class="application">libsoup</span> should do:
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="preproc">#include</span><span class="normal"> </span><span class="string">&lt;libsoup/soup.h&gt;</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
or, for <span class="application">libsoup-gnome</span>:
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="preproc">#include</span><span class="normal"> </span><span class="string">&lt;libsoup/soup-gnome.h&gt;</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
Including individual headers besides the two main header files is not
recommended. You may include both <code class="literal">soup.h</code> and
<code class="literal">soup-gnome.h</code> (though this is not required; the
latter automatically includes the former).
</p>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.18</div>
</body>
</html>